(function($, doc) {
	$.init();
	$.plusReady(function() {
		doc.getElementById('password').focus();
		doc.getElementById('password').style.borderBottom='1px solid #4cd964';
	});
	
	doc.getElementById('do_pwd').addEventListener('tap', function() {
		var userinfo = app.getState();
		var pwdObj=document.getElementById('password');
		var repwdObj=document.getElementById('repassword');
		var num = /^(?![0-9]*$)[a-zA-Z0-9]{6,16}$/;
		if(pwdObj.value.trim()==''){
			$.alert('请输入密码');
			pwdObj.focus();
			return false;
		}
		if(repwdObj.value.trim()==''){
			$.alert('请输入确认密码');
			repwdObj.focus();
			return false;
		}
		if(pwdObj.value.trim()!=repwdObj.value.trim()){
			$.alert('两次输入的密码不一致');
			pwdObj.focus();
			return false;
		}
		
		var pwdval=pwdObj.value.trim();
		if(!(num.exec(pwdval))){
			$.alert('密码必须是6-16位的数字、字符组合 (不能是纯数字 )');
			pwdObj.focus();
			return false;
		}
		
		var pwdInfo = {
				user_id: userinfo.user_id,
				password: pwdval
			};

			pwdInfo.passwd = md5(pwdInfo.password);
			
			mui.ajax({
			url: pwdurl,
			data: pwdInfo,
			async: true,
			dataType: 'json',
			crossDomain: true, //强制使用5+跨域
			type: 'post',
			timeout: 10000,
			success: function(res) {
					console.log(JSON.stringify(res));
					// 请求成功
					if(res.status < 1) {
						mui.toast(res.msg);
					} else {
		                mui.toast(res.msg);
						mui.back();
					}
				},
				error: function(xhr, type, errorThrown) {
					//console.log(JSON.stringify(xhr));
					//console.log(JSON.stringify(type));
					//console.log(JSON.stringify(errorThrown));
					mui.toast('设置登录密码失败222！');
				}
		});
	
	});

}(mui, document));


function pwd_foc(){
	document.getElementById('password').style.borderBottom='1px solid #4cd964';
	document.getElementById('repassword').style.borderBottom='1px solid #929292';
}
		
function repwd_foc(){
	document.getElementById('password').style.borderBottom='1px solid #929292';
	document.getElementById('repassword').style.borderBottom='1px solid #4cd964';
}
		